<?php session_start();

if (empty($_SESSION['nombre']))
	echo "<meta http-equiv='Refresh' content='0;url=../index.php'>";

require '../config.php';
$cliente = $_REQUEST['nombrecliente'];
$ID = $_REQUEST['ID'];
$registros=mysql_query("select * from  clientesventas where tipo=3 and activo=1 and nombre='".$cliente."' limit 1");
	
	
$row = mysql_fetch_array($registros);
echo   "<table class='table table-bordered'>";
echo   "<tr>";
echo   "<th>Identificador</th><th>Nombre</th><th>Direcci&oacute;n</th>";
echo   "</tr>";
echo   "<tbody>";
echo   "<td >".$row['idclientesventas']."</td>";
echo   "<td>"._convert($row['nombre'])."</td>";
echo   "<td>"._convert($row['direccion'])."</td>";

echo   "</tr>";
echo   "</tbody>";
echo   "</table>";

echo "<div>";
echo "<label class='description' for='telefonover'>N&uacute;mero de Contrato: </label>";
echo "<select id='conts' onchange='cambiarContrato();'>";
echo "<option value='0' selected>Seleccione el Contrato</option>";
$query2="SELECT idcontratos FROM hossbd.contratos where activo=1 and cliente = ".$row['idclientesventas'];
$result2 = mysql_query($query2,$conexion);
if(mysql_num_rows($result2)>0)
{
	while($row2 = mysql_fetch_assoc($result2))
	{

		echo "<option value=".$row2['idcontratos'].">".$row2['idcontratos']."</option>";

	}

}
echo "</select>";
echo "</div>";


function _convert($content) {
	if(!mb_check_encoding($content, 'UTF-8')
	OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {

		$content = mb_convert_encoding($content, 'UTF-8');

		if (mb_check_encoding($content, 'UTF-8')) {
			// log('Converted to UTF-8');
		} else {
			// log('Could not converted to UTF-8');
		}
	}
	return $content;
}
?>